package com.example.myapplication.Sign;

import static java.util.regex.Pattern.*;

import android.text.TextUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidUtils {

    public static String checkInfo(String phone, String pwd, String repwd){
        if (TextUtils.isEmpty(phone)){
            return "手机号码不能为空";
        }
        if (!checkTel(phone)){
            return "手机号码不合法";
        }
        if (TextUtils.isEmpty(pwd)){
            return "密码不能为空";
        }
        if (!pwd.equals(repwd)){
            return "两次输入密码不一致";
        }
        return null;
    }

    //正则匹配手机号码
    public static boolean checkTel(String tel){
        Pattern p = compile("^[1][3,4,5,7,8,9][0-9]{9}$");
        Matcher matcher = p.matcher(tel);
        return matcher.matches();
    }
}